﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using BLL.Workers;

namespace WinSvc.Workflows
{
    public partial class Service1 : ServiceBase
    {
        WorkflowService wfService;

        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            StartWorkflowService();
        }

        protected override void OnStop()
        {
            StopWorkflowService();
        }

        private void StartWorkflowService()
        {
            if (this.wfService != null)
            {
                if (!this.wfService.IsActive)
                {
                    this.wfService.Start();
                }
            }
            else
            {
                this.wfService = new WorkflowService();
                this.wfService.Start();
            }
        }

        private void StopWorkflowService()
        {
            if (this.wfService != null && this.wfService.IsActive)
            {
                this.wfService.Stop();
            }
        }
    }
}
